/*
	Copyright 3008 Daniel Winkler
	Email: danthemanwinkler@gmail.com
	Cell #: 513-657-3653
	
	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
package danlib;

public class DVec4
{
	public double x;
	public double y;
	public double z;
	public double w;
	
	public DVec4(double x, double y, double z, double w)
	{
		this.x = x;
		this.y = y;
		this.z = z;
		this.w = w;
	}
	
	public DVec4()
	{
		x = 0.0;
		y = 0.0;
		z = 0.0;
		w = 0.0;
	}
	
	public DVec4( DVec4 v )
	{
		x = v.x;
		y = v.y;
		z = v.z;
		w = v.w;
	}
	
	public void set(DVec4 p)
	{
		x = p.x;
		y = p.y;
		z = p.z;
		w = p.w;
	}
	
	public void add(DVec4 p)
	{
		x += p.x;
		y += p.y;
		z += p.z;
		w += p.w;
	}
	
	public void sub(DVec4 p)
	{
		x -= p.x;
		y -= p.y;
		z -= p.z;
	}
	
	public double dot( DVec4 v )
	{
		return x*v.x + y*v.y;
	}
	
	public DVec4 mul(double v)
	{
		x *= v;
		y *= v;
		z *= v;
		w *= v;
		return this;
	}
	
	public DVec4 mulr(double v)
	{
		double x = this.x * v;
		double y = this.y * v;
		double z = this.z * v;
		double w = this.w * v;
		return new DVec4( x, y, z, w );
	}
	
	public DVec4 mulr(DVec4 p)
	{
		double x = this.x * p.x;
		double y = this.y * p.y;
		double z = this.z * p.z;
		double w = this.w * p.w;
		return new DVec4( x, y, z, w );
	}
	
	public void div(double v)
	{
		x /= v;
		y /= v;
	}
	
	public void normalize()
	{
		div(mag());
	
	}
	
	public double mag()
	{
		return Math.sqrt(Math.pow(x,2) + Math.pow(y,2));
	}
	
	public String toString()
	{
		return "x: " + x + ", y: " + y + ", z: " + z;
	}

}